package com.lark.oapi.sample.apiall.wikiv2;

import com.lark.oapi.Client;
import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.wiki.v2.model.*;

import java.util.HashMap;

// DELETE /open-apis/wiki/v2/spaces/:space_id/members/:member_id
public class DeleteSpaceMemberSample {

    public static void main(String arg[]) throws Exception {
        // 构建client
        Client client = Client.newBuilder("appId", "appSecret").build();

        // 创建请求对象
        DeleteSpaceMemberReq req = DeleteSpaceMemberReq.newBuilder()
                .spaceId("7008061636015554580")
                .memberId("g64fb7g7")
                .member(Member.newBuilder()
                        .memberType("openid")
                        .memberRole("admin")
                        .type("user")
                        .build())
                .build();

        // 发起请求
        DeleteSpaceMemberResp resp = client.wiki().v2().spaceMember().delete(req);

        // 处理服务端错误
        if (!resp.success()) {
            System.out.println(String.format("code:%s,msg:%s,reqId:%s"
                    , resp.getCode(), resp.getMsg(), resp.getRequestId()));
            return;
        }

        // 业务数据处理
        System.out.println(Jsons.DEFAULT.toJson(resp.getData()));
    }
}
